#include<iostream>
using namespace std;
void DFS(int map[][200], int visit[],int i, int n)
{
	int j = 1;
	for (j; j <= n; j++)
	{
		if (visit[j] == 0 && map[i][j] == 1)
		{
			visit[j] = 1;
			DFS(map, visit, j, n);

		}
	}
}
int main()
{
	int map[200][200] = { 0 };
	int visit[200] = { 0 };
	int n, k,sum=0;
	cin >> n;
	cin >> k;

	while (k--)
	{
		int i, j;
		cin >> i >> j;
		map[i][j] = 1;
		map[j][i] = 1;
		
	}
	int i = 0;
	for (i=1; i <= n; i++)
	{
		if (visit[i] == 0)
		{
			visit[i] = 1;
			sum++;
		}
		int j = 1;
		for (j; j <= n; j++)
		{
			if (visit[j] == 0 && map[i][j] == 1)
			{
				visit[j] = 1;
				DFS(map, visit, j, n);

			}
		}

	}
	cout << sum;
}